package service.impl;

import java.util.Date;
import java.util.List;

import dao.UnAssessDao;

import model.Assessor;
import model.UnAssess;
import model.User;
import service.AssessorManager;
import service.UnAssessManager;

public class UnAssessManagerImpl implements UnAssessManager {
	private UnAssessDao unAssessDao;
	public UnAssessDao getUnAssessDao() {
		return unAssessDao;
	}
	public void setUnAssessDao(UnAssessDao unAssessDao) {
		this.unAssessDao = unAssessDao;
	}
	public void addUnAssess(Date date, User user, Assessor assessor)
			throws Exception {
		// TODO Auto-generated method stub
			try {
				UnAssess unAssess = new UnAssess();
				unAssess.setDate(date);
				unAssess.setUser(user);
				unAssess.setAssessor(assessor);
				unAssessDao.save(unAssess);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
				throw new Exception("向数据库添加未评审的记录时出现异常");
			}
	}
	
	public List<UnAssess> getUnAssessByUser(Assessor assessor) throws Exception{
		try {
			List<UnAssess> unAssesses = unAssessDao.getUnAssessByAssessor(assessor);
			return unAssesses;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			throw new Exception("根据user查找待评审的记录时出现异常");
		}
	}
}
